package com.CMS.client.datasource;

import com.CMS.client.CMSConstants;
import com.CMS.client.CMSMessage;
import com.google.gwt.core.client.GWT;
import com.smartgwt.client.data.fields.DataSourceBooleanField;
import com.smartgwt.client.data.fields.DataSourceDateTimeField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;

public abstract class BaseDataSource extends GwtRpcDataSource{

	private String id = "id";
	private String addDate = "addDate";
	private String modDate = "modDate";
	private String flagDelete = "flagDelete";
	private String description = "description";
	
	protected CMSConstants constants = GWT.create(CMSConstants.class);
	
	protected DataSourceTextField descriptionField = new DataSourceTextField(getDescription(),constants.titleBaseGridDescription());
	protected DataSourceDateTimeField addDateField = new DataSourceDateTimeField(getAddDate(),constants.titleBaseGridAddDate());
	protected DataSourceDateTimeField modDateField = new DataSourceDateTimeField(getModDate(),constants.titleBaseGridModDate());
	protected DataSourceBooleanField flagDeleteField = new DataSourceBooleanField(getFlagDelete(),constants.titleBaseGridFlagDelete());
	protected DataSourceIntegerField idField = new DataSourceIntegerField(getId(),constants.titleBaseGridId());
	
	protected CMSMessage message = GWT.create(CMSMessage.class);

	public BaseDataSource(){
		addField(idField);
		addField(addDateField);
		addField(modDateField);
		addField(flagDeleteField);
		addField(descriptionField);
		
		idField.setCanEdit(false);
		addDateField.setCanEdit(false);
		modDateField.setCanEdit(false);
		idField.setPrimaryKey(true);
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getAddDate() {
		return addDate;
	}
	public void setAddDate(String addDate) {
		this.addDate = addDate;
	}
	public String getModDate() {
		return modDate;
	}
	public void setModDate(String modDate) {
		this.modDate = modDate;
	}
	public String getFlagDelete() {
		return flagDelete;
	}
	public void setFlagDelete(String flagDelete) {
		this.flagDelete = flagDelete;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
}
